main
Sub Main
	dim doc
	Set doc=Application.ActiveDocument
	
	dim args
	args = inputbox("REFDES PIN1,PIN2" ,args,"U11 A1,A2")
	args = ucase(trim(args))	
	dim s,ls,i
	s = split(args," ")
	ls = ubound(s)-lbound(s)+1
	dim oref	
	oref = trim(s(0))	
	
	dim ostr
	ostr=""
	dim compobj
	set compobj = doc.components(oref)
	if compobj is nothing then 
		msgbox "wrong input"
	else	
		IF ls=2 Then
			dim cs,lcs
			cs = split(s(1),",")
			lcs = ubound(cs)-lbound(cs)+1
			dim pins,pin,item
			set pins = compobj.pins
			'msgbox pins.count
			for each pin in pins
				pinname= pin.name
				'msgbox pinname
				for i=0 to lcs-1
					item= oref & "." & trim(ucase(cs(i)))
					if pinname = item then
						if ostr="" then 
							ostr =pin.net.name
						else
							ostr = ostr & ","
							ostr = ostr & pin.net.name
						end if						
						ncount = ncount+1
					end if	
				next	
			next
		END If
		
		dim ws : set ws = CreateObject("WScript.Shell")
		dim varName : varName = "PADS_SHORTCUT_ROOT"
		dim regPath : regPath ="HKEY_CURRENT_USER\Software\MyApp\PADS\" & varName
		dim varValue : varValue = ws.RegRead(regPath)
		
		dim clipfile,scriptfile
		clipfile = varValue & "\cache\clipboard.txt"
		scriptfile = varValue & "\Skill\includes\CopyToClipboard.vbs"

		
		dim fso,fw
		set fso=createobject("scripting.filesystemobject")
		set fw = fso.createtextfile(clipfile)
		fw.write ostr
		fw.close
		set fw=nothing
		set fso = nothing
		
		dim ocmd
		ocmd =  "cscript " & scriptfile & " " & clipfile
		ws.run ocmd,true
		set ws = nothing

		'Clipboard ostr
		msgbox "copy to clipboard"	
	end if
End Sub

